package com.usefullc.system.enums;


import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 作业模板时间周期
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum JobTemplatePeriodEnum {

    CUSTOM(-1, "自定义",""),
    SECOND(0, "秒钟","yyyy-MM-dd HH:mm:ss"),
    MINUTE(1, "分钟","yyyy-MM-dd HH:mm"),
    HOUR(2, "小时","yyyy-MM-dd HH"),
    DAY(3, "天","yyyy-MM-dd"),
    WEEK(4, "周","yyyy-MM"),
    MONTH(5, "月","yyyy-MM"),
    QUARTER(6, "季度", "yyyy-MM"),
    YEAR(7, "年", "yyyy"),



    ;


    private int code;
    private String value;
    private String format;

    JobTemplatePeriodEnum(int code, String value,String format) {
        this.code = code;
        this.value = value;
        this.format = format;
    }



    public static JobTemplatePeriodEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (JobTemplatePeriodEnum s : JobTemplatePeriodEnum.values()) {
            if (s.getCode() == code) {
                return s;
            }
        }
        return null;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getValue() {


        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }


    public String getFormat() {
        return format;
    }
}
